package com.ten.shou.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ten.common.core.entity.TblZone;
import com.ten.common.core.vo.Result;
import com.ten.shou.service.ZoneService;
import com.ten.shou.vo.ZoneId;
import com.ten.shou.vo.ZoneVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author ：杨（1964958771@qq.com）
 * @date ：Created in 2022/12/7 16:28
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/home/zone")
@Api(tags = "专区接口类")
public class ZoneController {
    @Resource
    private ZoneService zoneService;

    @ApiOperation(value = "根据条件分页查询专区信息")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "current", value = "当前页码"),
                    @ApiImplicitParam(name = "pageSize", value = "每页显示的条数")
            }
    )
    @PostMapping("getAllZone/{current}/{pageSize}")
    public Result<IPage<TblZone>> getAllZone(@PathVariable(required = true) Integer current, @PathVariable(required = true) Integer pageSize, @RequestBody ZoneVo zoneVo) {
        return zoneService.getAllZone(current, pageSize, zoneVo);
    }

    @ApiOperation(value = "根据id删除信息")
    @PostMapping("/deleteZone")
    public Result deleteZone(@RequestBody ZoneId zoneId) {
        return zoneService.deleteByIds(zoneId);
    }

    @PostMapping("changeStatus/{id}/{isDisable}")
    public Result changeStatus(@PathVariable String id,@PathVariable int isDisable){
       return zoneService.updateStatus(id,isDisable);
    }
    @PostMapping("addZone")
    public Result addZone(@RequestBody TblZone tblZone){
        return zoneService.insertAllZone(tblZone);
    }
}
